<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let aa=new Set([1,1,2,3,4,5,5])
        console.log(aa)
        console.log([...aa],Array.from(aa))
        aa.add(45)
        for(i of aa){
            console.log(i)
        }
        console.log(aa.size)
        //判断有没有
        console.log(aa.has(5))
        //清除
        // aa.clear()
        // console.log('aaa',aa,'清除完成')
        let arr=['11','22','33']
        //entries获取索引和值
        for(let [index,itme] of arr.entries()){
            console.log(index,itme)
        }
        //数值与对象去重
        let list=[1,2,2,'kerwin','kerwin',[1,2],[3,4],[1,2],{name:'kerwin'},{age:100},{name:'kerwin'}]
        function uni(shu){
            let res=new Set()
            return shu.filter((item)=>{
                //因为对象不能has判断 所以需要json.stringify转换为字符串
                let id=JSON.stringify(item)
                console.log(id,'item')
                if(res.has(id)){
                    return false
                }else{
                    res.add(id)
                    return true
                }
            })
        }
        console.log(uni(list))
    </script>
</body>
</html>